package org.qqcui.designpattern.patterns.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * 输出辅助类
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2022/5/6 14:30
 **/
public class OutputImpl {

    /**
     * 所有学院信息
     */
    private List<College> colleges;

    public OutputImpl(List<College> colleges) {
        this.colleges = colleges;
    }

    /**
     * 打印学院信息
     */
    public void printCollege() {
        Iterator<College> iterator = colleges.iterator();
        while (iterator.hasNext()) {
            College college = iterator.next();
            System.out.println("===================" + college.getName() + "====================");
            Iterator<Department> it = college.createIterator();
            printDepartment(it);
        }
    }

    /**
     * 打印学院下的专业信息
     * @param it
     */
    private void printDepartment(Iterator<Department> it) {
        while (it.hasNext()) {
            Department department = it.next();
            System.out.println(department.getName());
        }
    }
}
